import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:remixicon/remixicon.dart';
import 'package:super_person_app/constants/colors.dart';
import 'package:super_person_app/utils/constants.dart';

import 'my_logic.dart';

class MyPage extends StatelessWidget {
  const MyPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final logic = Get.find<MyLogic>();
    final state = Get.find<MyLogic>().state;

    return Scaffold(
      backgroundColor: const Color(0xffF3F6F5),
      body: ListView(
        padding: EdgeInsets.zero,
        children: [
          _header()
        ],
      ),
    );
  }

  Widget _header() {
      return SizedBox(
         height: 300.h,
         child: Stack(
           children: [
             Container(
               height: 180.h,
               decoration: const BoxDecoration(
                   color: Colors.transparent,
                   image: DecorationImage(
                       fit: BoxFit.cover,
                       image: AssetImage("assets/image/2.jpg")
                   )
               ),
               child: Column(
                 children: [
                   Container(
                     padding: EdgeInsets.only(
                         left: 16.w,
                         right: 16.w,
                         top: 30.h
                     ),
                     alignment: Alignment.centerRight,
                     child: IconButton(onPressed: () {}, icon: const Icon(Remix.settings_line)),
                   ),
                   Container(
                     padding: EdgeInsets.only(
                         left: 16.w,
                         right: 16.w,
                         top: 10.h
                     ),
                     child: Row(
                       children: [
                         CircleAvatar(
                           radius: 30.w,
                           backgroundImage: const CachedNetworkImageProvider(
                               "https://img2.baidu.com/it/u=3429727124,1164343535&fm=253&fmt=auto&app=120&f=JPEG?w=700&h=693"
                           ),
                         ),
                         Expanded(
                           child: Container(
                             height: 60.h,
                             padding: EdgeInsets.only(
                                 left: 16.w
                             ),
                             child: Row(
                               mainAxisAlignment: MainAxisAlignment.spaceBetween,
                               children: [
                                 Column(
                                   crossAxisAlignment: CrossAxisAlignment.start,
                                   mainAxisAlignment: MainAxisAlignment.center,
                                   children: [
                                     Row(
                                       children: [
                                         Text("崇璐莹", style: TextStyle(
                                             fontWeight: FontWeight.w600,
                                             fontSize: 18.sp
                                         ),),
                                         InkWell(
                                           child: Icon(
                                             Remix.edit_2_line,
                                             size: 16.sp,
                                           ),
                                         )
                                       ],
                                     ),
                                     Container(
                                       margin: EdgeInsets.only(
                                           top: 4.h
                                       ),
                                       padding: EdgeInsets.only(
                                         left: 4.w,
                                         right: 4.w,
                                       ),
                                       child: Text(
                                         "认证业主",
                                         style: TextStyle(
                                           fontSize: 12.sp,
                                         ),
                                       ),
                                       decoration: BoxDecoration(
                                           borderRadius: BorderRadius.all(Radius.circular(30.w)),
                                           border: Border.all(color: Colors.black, width: 0.8.w)
                                       ),
                                     )
                                   ],
                                 ),
                                 InkWell(
                                   child: Row(
                                     children: [
                                       Text("个人主页"),
                                       Icon(
                                         Remix.arrow_right_s_line,
                                         color: Colors.black,
                                         size: 22.sp,
                                       )
                                     ],
                                   ),
                                 )
                               ],
                             ),
                           ),
                         )
                       ],
                     ),
                   )
                 ],
               ),
             ),
             Positioned(
               top: 160.h,
               left: 16.w,
               right: 16.w,
               bottom: 0,
               child: Container(
                 padding: EdgeInsets.only(
                   left: 20.w,
                   right: 20.w,
                   top: 16.h,
                   bottom: 16.h
                 ),
                 decoration: BoxDecoration(
                     color: Colors.white,
                     borderRadius: BorderRadius.all(Radius.circular(6.w)),
                 ),
                 child: Column(
                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                   children: [
                      Row(
                        children: [
                          Image.asset("assets/image/1.png"),
                          Container(
                            padding: EdgeInsets.only(
                              left: 10.w
                            ),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                const Text("添加住处", style: TextStyle(
                                  fontWeight: FontWeight.w600,
                                ),),
                                Text("认识小区朋友，从这里开始...", style: TextStyle(
                                  color: const Color(0xffA5A5A5),
                                  fontSize: 12.sp
                                ),)
                              ],
                            ),
                          )
                        ],
                      ),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          _headerItem(Remix.edit_2_line, "认识邻里"),
                          _headerItem(Remix.edit_2_line, "手机门禁卡"),
                          _headerItem(Remix.edit_2_line, "一键缴费"),
                        ],
                      )
                   ],
                 ),
               ),
             )
           ],
         ),
      );
  }

  Widget _headerItem(IconData icon, String text) {
    return Column(
      children: [
        Icon(icon, color: BasicColor.mainColor, size: 30.sp,),
        Text(text)
      ],
    );
  }
}
